package com.aj.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TextUtil {
	// 距离格式化
	public static String transformDistance(int s) {
		String text = null;
		if (s < 2000)
			text = s + "米";
		else if (s < 200000) {
			int ss = s / 100;
			text = ss / 10.0 + "公里";
		} else
			text = s / 1000 + "公里";

		return text;
	}

	public static boolean isEmpty(String str) {
		if (str == null) {
			return true;
		} else {
			if (str.length() == 0) {
				return true;
			} else {
				return false;
			}
		}
	}
	
	public static boolean equals(String str1, String str2) {
		if ( (str1 == null)  && ( str2 == null ) )
			return true;
		else if ( (str1 != null)  && ( str2 == null ) )
			return false;
		else if ( (str1 == null)  && ( str2 != null ) )
			return false;
		else {
			if ( str1.equals(str2) )
				return true;
			else
				return false;
		}
	}
	
	//判断是否为数字
	public static boolean isNum(String str){ 
		return str.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$"); 
	} 
}
